import { createSlice } from "@reduxjs/toolkit"


const home = createSlice({
    name: "home",
    initialState: {
        bannerList: [
            {
                "link": "1",
                "alt": "1",
                "img": "https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics3.baidu.com%2Ffeed%2Fc75c10385343fbf21d92f25a042f558c64388fef.jpeg%40f_auto%3Ftoken%3De727fb4761f8456cca89c6a4a8355490&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1692118800&t=31368c5fca3a31f41cb8ca13700490ff",
                "bannerid": "banner_3b7e9da6-49f0-406b-bc4e-854b832cec88",
                "flag": true
            }
        ]
    },
    reducers: {
        addBanner(state, action) {
            state.bannerList.push(action.payload);
        },
        removeBanner(state,action) {
            state.bannerList = state.bannerList.filter(item=>item.bannerid===action.payload);
        }
    }
});

// 对外暴露：actions
export const {addBanner,removeBanner} = home.actions;

// 对外暴露

// 对外暴露reducer
export default home.reducer;

